package com.wn55.hrms.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wn55.hrms.entity.Trainer;
import com.wn55.hrms.mapper.TrainerMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zy
 * @date 2022/5/5 10:13
 */
@Service
public class TrainerService {
    @Autowired
    TrainerMapper trainerMapper;

    public PageInfo<Trainer> trainerList(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<Trainer> list = trainerMapper.selectByName(name);
        return new PageInfo<>(list);

    }

    public void modify(Trainer trainer) {
        trainerMapper.update(trainer);
    }

    public void add(Trainer trainer) {
        trainerMapper.insert(trainer);
    }

    public void removeBykey(int id) {
        trainerMapper.deleteByPrimaryKey(id);
    }
}
